{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 导入包和数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-05T16:17:00.721660Z",
     "start_time": "2020-02-05T16:16:58.139964Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "E:\\Anaconda\\envs\\ml\\lib\\site-packages\\sklearn\\externals\\joblib\\__init__.py:15: DeprecationWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.\n",
      "  warnings.warn(msg, category=DeprecationWarning)\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import jieba\n",
    "import re\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.metrics import f1_score,precision_score,recall_score,accuracy_score\n",
    "import sklearn\n",
    "from sklearn import svm\n",
    "import itertools\n",
    "import collections\n",
    "import array\n",
    "import os\n",
    "from sklearn.model_selection import cross_val_score\n",
    "from sklearn.externals import joblib\n",
    "# import joblib 如果你的sklearn版本大于0.21,你需要单独安装这个包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-05T16:12:23.367853Z",
     "start_time": "2020-02-05T16:12:22.004323Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     工作职责：   1、参与多种平台前端应用开发，包括PC端及移动端产品；    2、负责前端交...\n",
       "1     岗位职责： 1、对微信架构足够了解，参与开发一套稳定的支撑公司大业务量和高速发展的小程序，公...\n",
       "2     任职要求：     计算机相关专业毕业，本科及以上学历。     理解web标准，熟悉web...\n",
       "3     1、负责项目PC端和移动端的web前端开发工作，配合调取后端工程师的API接口实现功能; 2...\n",
       "4     工作职责: 1、负责公司业务系统前端架构设计和技术选型； 2、负责业务系统Web前端页面开发...\n",
       "                            ...                        \n",
       "95    岗位职责： 1、带领实施团队完成软件项目实施，管理APP开发团队； 2、分析客户需求，完成项...\n",
       "96    1. 负责公司系统软件产品、平台网站和手机应用界面风格设计、图标效果制作 2. 优化网站界面...\n",
       "97    岗位职责:  1、严格遵守公司项目管理流程，保证开发质量、提高开发效率；2、参与产品模块、项...\n",
       "98    岗位职责： 1、负责PC及移动端产品的前端代码开发工作； 2、负责对产品页面性能的优化和维护...\n",
       "99    岗位职责： 1. 负责民品项目（售前、合同等）/产品的Web前端模块的需求、设计与开发并能够...\n",
       "Name: 0, Length: 100, dtype: object"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df=pd.read_excel('font.xlsx').iloc[:100,1]\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 模块"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## JobinfoSpliter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-05T16:12:25.620129Z",
     "start_time": "2020-02-05T16:12:25.414424Z"
    },
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "class JobinfoSpliter:\n",
    "    '''\n",
    "        Constructor:\n",
    "                    JobinfoSpliter(jobinfo,stopwords,addwords)\n",
    "                    \n",
    "                    jobinfo   DataFrame\n",
    "                              分类所使用大文本\n",
    "                    stopwords 停用词txt文件 一行一个词\n",
    "                    addwords  增加词txt文件 一行一个词\n",
    "                   \n",
    "                    \n",
    "        Attributes:\n",
    "                    jobinfo DataFrame\n",
    "                            需要进行分类的jobinfo\n",
    "                    sen     DataFrame\n",
    "                            jobinfo分裂出来的句子\n",
    "                    words   DataFrame\n",
    "                            句子分裂后提取的词\n",
    "                    stopwords str \n",
    "                              stopwords的txt文件地址\n",
    "                    addwords  str \n",
    "                              addwords 的txt文件地址\n",
    "        Functions:\n",
    "                    sen_split() 将jobinfo分成多个句子\n",
    "                    sen2words() 将句子分成多个单词\n",
    "                    \n",
    "                    get_words() 调用sen_split(),sen2words()，直接获得分割为词的Dataframe\n",
    "    '''\n",
    "    \n",
    "\n",
    "    def __init__(self,jobinfo,stopwords,addwords):\n",
    "        self.jobinfo=jobinfo\n",
    "        self.stopwords=stopwords\n",
    "        self.addwords=addwords\n",
    "        self.sen=[]\n",
    "        self.words=[]\n",
    "        \n",
    "    def sen_split(self):\n",
    "        '''\n",
    "            将self.jobinfo分裂成多个句子，其结果赋给self.sen,并将结果返回\n",
    "            \n",
    "            Parameters: None\n",
    "            Returns: DataFrame\n",
    "                     self.jobinfo分裂后的句子\n",
    "            \n",
    "        '''\n",
    "        result=list()\n",
    "        mode = re.compile('[a-z1-9][、.．）)]+')\n",
    "        mode2=re.compile('[\\\\xa0]+')\n",
    "        mode3=re.compile('[、.．：:（）()]')\n",
    "        \n",
    "        try:\n",
    "            jobinfo=self.jobinfo.values\n",
    "        except AttributeError as e:\n",
    "            print(\"属性jobinfo类型错误,请确保传入的类型为DataFrame。\")\n",
    "        else:           \n",
    "            for i in jobinfo:\n",
    "                temp=re.split('[；。，]+',i)\n",
    "                for j in np.arange(len(temp)):\n",
    "                    temp[j]=mode.sub('',temp[j])\n",
    "                    temp[j]=mode2.sub('',temp[j]).strip()\n",
    "                    temp[j]=mode3.sub('',temp[j]).strip()\n",
    "                result.append(temp)\n",
    "\n",
    "            sen=pd.DataFrame()\n",
    "\n",
    "            for i in result:\n",
    "                temp=pd.DataFrame(i)\n",
    "                sen=pd.concat([temp,sen],axis=0)\n",
    "            self.sen=sen.reset_index(drop=True)\n",
    "            return sen\n",
    "        \n",
    "    def sen2words(self):\n",
    "        '''\n",
    "            将self.sen分裂成词，其结果赋给self.words,并将结果返回\n",
    "            \n",
    "            Parameters: None\n",
    "            Returns: DataFrame\n",
    "                     self.sen分裂出来的词\n",
    "        '''\n",
    "        try:\n",
    "            sen=self.sen.iloc[:,0].values\n",
    "            df=pd.DataFrame(np.zeros(self.sen.shape[0]))\n",
    "        except AttributeError as e:\n",
    "            print(\"属性sen类型错误,请在使用本方法前使用sen_split()或是使用get_words()直接得到结果。\")\n",
    "        else:\n",
    "            with open(self.stopwords,'r+',encoding='utf8') as f:\n",
    "                stopwords=[ i.strip('\\n') for i in f.readlines()]\n",
    "\n",
    "            jieba.load_userdict(self.addwords)\n",
    "\n",
    "            words=list()\n",
    "\n",
    "            for sentence in sen:\n",
    "                word=jieba.lcut(sentence)\n",
    "                temp=list()\n",
    "                for w in word:\n",
    "                    if w not in stopwords and w!='\\xa0':\n",
    "                        temp.append(w)\n",
    "                words.append(temp)\n",
    "            df.iloc[:,0]=words\n",
    "\n",
    "            self.words=df.reset_index(drop=True)\n",
    "\n",
    "            return df\n",
    "\n",
    "    def get_words(self):\n",
    "        '''\n",
    "            获得分割为词的Dataframe\n",
    "            \n",
    "            Parameters: None\n",
    "            Returns: DataFrame\n",
    "                     分割成词的结果\n",
    "        '''\n",
    "        self.sen_split()\n",
    "        self.sen2words()\n",
    "        \n",
    "        result = self.words\n",
    "        return result\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-05T16:12:31.144859Z",
     "start_time": "2020-02-05T16:12:29.091710Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache C:\\Users\\lenovo\\AppData\\Local\\Temp\\jieba.cache\n",
      "Loading model cost 1.118 seconds.\n",
      "Prefix dict has been built succesfully.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[岗位职责, 民品, 项目, 售前, 合同, 产品, Web, 前端, 模块, 需求, 设计...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>[产品, 后台, 开发人员, 保持良好, 沟通]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>[快速, 理解消化, 各类, 需求]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>[落实, 具体, 研发]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>[服务器端, 相关]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>[交互, 体验, 产品设计, 方面, 见解]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>[做到, 知识, 共享, 遵守, 日常, 管理制度]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>[基于, 项目, 应用, 挖掘]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>[行业, 应用, 里, 各类, 平台, 产品, 提供, 有效, 改良, 建议]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>[任职, 1年, web, 实际, 开发, 经验, 熟练, HTML, CSS, javas...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>[对于, 页面, 效果, 实现, 足够, 经验, 熟练, jQuerBootstraBack...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>[主流, GIS, 工具]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>[ArcGISSuperMap, 软件, 优先, 考虑]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>[前后, 分离, 开发, 经验, 职能, 类别, Web, 前端开发, 关键字, 前端开发,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>[岗位职责, PC, 移动, 产品, 前端, 代码, 开发]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>[产品, 页面, 性能, 优化, 维护]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>[持续, 提升, 用户, 体验]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>[后端, 工程师, 协作]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>[高效, 完成, 产品, 数据, 交互, 动态, 信息, 展现]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>[学习, 研究, 技术, 满足, 产品, 需求]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>[根据, 开发, 过程, 体验, 产品, 提出, 改进, 建议]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>[任职, 计算机相关, 专业, 大专, 以上学历]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>[页面, 布局, 方式]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>[移动, 响应, 页面, 布局, 方式]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>[PC, 端及, 移动, 端的, 前端开发, 浏览器, 兼容, 移动, 机型, 适配, 方式...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>[相关, 人员, 沟通, 合作]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>[自学, 沟通, 表达能力, 吃苦耐劳, 精神]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>[责任心]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>[职能, 类别, 软件, 工程师, 微信, 分享]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>[岗位职责, 严格遵守, 公司, 项目管理, 流程]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2071</th>\n",
       "      <td>[包括, PC, 端及, 移动, 产品]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2072</th>\n",
       "      <td>[前端, 交互, 实现]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2073</th>\n",
       "      <td>[根据, 产品, 需求, 设计, 效果图, 快速, 开发, 前端, 界面, 功能]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2074</th>\n",
       "      <td>[前端, 模块, 测试, 优化]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2075</th>\n",
       "      <td>[页面, 性能, 优化]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2076</th>\n",
       "      <td>[持续, 提升, 用户, 体验]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2077</th>\n",
       "      <td>[通用, 功能, SDK, 基础, 组件, 研发]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2078</th>\n",
       "      <td>[提升, 代码, 复用, 率]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2079</th>\n",
       "      <td>[提升, 团队, 开发, 效率, 质量]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2080</th>\n",
       "      <td>[岗位, 计算机相关, 专业]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2081</th>\n",
       "      <td>[本科, 以上学历]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2082</th>\n",
       "      <td>[3年, 前端开发, 经验]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2083</th>\n",
       "      <td>[HTML, CSS, JavaScripAjaJquerESSASS, 技术]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2084</th>\n",
       "      <td>[coding, 能力]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2085</th>\n",
       "      <td>[处理, 各个, 终端, 页面, 兼容性]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2086</th>\n",
       "      <td>[手机, web, 开发]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2087</th>\n",
       "      <td>[手机, web, 开发, 一些, 特性]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2088</th>\n",
       "      <td>[响应]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2089</th>\n",
       "      <td>[兼容性]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2090</th>\n",
       "      <td>[触屏, 事件处理, 熟练掌握]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2091</th>\n",
       "      <td>[移动, 开发, IDE, 优先, HBuilder]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2092</th>\n",
       "      <td>[实际, 项目, 经验]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2093</th>\n",
       "      <td>[相关, JSON, 技术]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2094</th>\n",
       "      <td>[vujBootstraAUI, 一个, 多个, 前端, 框架]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2095</th>\n",
       "      <td>[基于, 框架, 前端, MV, 开发, 模式]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2096</th>\n",
       "      <td>[nod, js, ,, gulp, ,, webpack, ,, browserify, ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2097</th>\n",
       "      <td>[模块化]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2098</th>\n",
       "      <td>[前后, 分离]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2099</th>\n",
       "      <td>[流行, 语法, 包装, 器如, LESSSASSTypeScript, 经验]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2100</th>\n",
       "      <td>[职能, 类别, 微信, 分享]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2101 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                      0\n",
       "0     [岗位职责, 民品, 项目, 售前, 合同, 产品, Web, 前端, 模块, 需求, 设计...\n",
       "1                              [产品, 后台, 开发人员, 保持良好, 沟通]\n",
       "2                                    [快速, 理解消化, 各类, 需求]\n",
       "3                                          [落实, 具体, 研发]\n",
       "4                                            [服务器端, 相关]\n",
       "...                                                 ...\n",
       "2096  [nod, js, ,, gulp, ,, webpack, ,, browserify, ...\n",
       "2097                                              [模块化]\n",
       "2098                                           [前后, 分离]\n",
       "2099           [流行, 语法, 包装, 器如, LESSSASSTypeScript, 经验]\n",
       "2100                                   [职能, 类别, 微信, 分享]\n",
       "\n",
       "[2101 rows x 1 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "spliter=JobinfoSpliter(df,'stopwords.txt','addwords.txt')\n",
    "spliter.sen_split()\n",
    "spliter.sen2words()\n",
    "spliter.get_words()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## JobinfoClassifier"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-05T16:12:38.656765Z",
     "start_time": "2020-02-05T16:12:38.426382Z"
    },
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "class JobinfoClassifier(JobinfoSpliter):\n",
    "    '''\n",
    "        Constructor:\n",
    "                    JobClassifier(model,jobinfo,stopwords,addwords,words_id)\n",
    "                    \n",
    "                    model     .model结尾文件\n",
    "                              sklearn训练完成的模型\n",
    "                    jobinfo   DataFrame\n",
    "                              分类所使用大文本\n",
    "                    stopwords 停用词txt文件 一行一个词\n",
    "                    addwords  增加词txt文件 一行一个词\n",
    "                    words_id  词向量id文件  每一行为 Word-id(如 前端-1)\n",
    "                   \n",
    "                    \n",
    "        Attributes:\n",
    "                    model   sklearn.svm.classes.SVC\n",
    "                            导入的模型\n",
    "                    words_id str \n",
    "                             词id的txt文件地址\n",
    "                    jobinfo DataFrame\n",
    "                            需要进行分类的jobinfo\n",
    "                    sen     DataFrame\n",
    "                            jobinfo分裂出来的句子\n",
    "                    words   DataFrame\n",
    "                            句子分裂后提取的词\n",
    "                    stopwords str \n",
    "                              stopwords的txt文件地址\n",
    "                    addwords  str \n",
    "                              addwords的txt文件地址\n",
    "                    ids     dict\n",
    "                            词id字典 key:词，value:id\n",
    "                    vec     list\n",
    "                            词向量\n",
    "                    result  DataFrame\n",
    "                            模型分类的结果，一共3列，由[句子,分割后的词，分类]组成。\n",
    "                            分别对应self.sen,self.words,分类结果\n",
    "        \n",
    "        Functions:\n",
    "                    sen_split() 将jobinfo分成多个句子\n",
    "                    sen2words() 将句子分成多个单词\n",
    "                    word2vec()  将单词化为词向量\n",
    "                    \n",
    "                    load_words_id() 读取词向量的id文件\n",
    "                    predict()       预测输入的文本的类别\n",
    "                    get_words_frequency() 获得词分类后,每一个类别中不同词汇的出现频率\n",
    "    '''\n",
    "    def __init__(self,model,jobinfo,stopwords,addwords,words_id):\n",
    "        super().__init__(jobinfo,stopwords,addwords)\n",
    "        self.model=joblib.load(model)\n",
    "        self.words_id=words_id\n",
    "        self.ids=[] \n",
    "        self.vec=[] \n",
    "        self.result=[]\n",
    "        \n",
    "    def load_words_id(self):\n",
    "        '''\n",
    "            读取词ID文件,其结果赋给self.ids,并返回结果\n",
    "            \n",
    "            Parameters: None\n",
    "            Returns: dict\n",
    "                     self.ids key:词 values:id\n",
    "        '''\n",
    "        with open(self.words_id,'r',encoding='utf8') as f: \n",
    "            ids=dict()\n",
    "            for i in f.readlines():\n",
    "                try:\n",
    "                    i=i.replace('\\n','')\n",
    "                    temp=i.split('-')\n",
    "                    temp[1]=int(temp[1])\n",
    "                    ids[temp[0]]=temp[1]\n",
    "                except IndexError:\n",
    "                    continue\n",
    "        self.ids=ids\n",
    "        \n",
    "        return ids\n",
    "\n",
    "    def word2vec(self):\n",
    "        '''\n",
    "            将self.words转换成词向量,其结果赋给self.vec,并返回改结果\n",
    "            \n",
    "            Parameters: None\n",
    "            Returns: list\n",
    "                     self.vec 词向量\n",
    "        '''\n",
    "        X=list()\n",
    "        for t in self.words.values:\n",
    "            vec=array.array('l',[0]*len(self.ids))\n",
    "            for word in t[0]:\n",
    "                if word not in self.ids:\n",
    "                    continue\n",
    "                vec[self.ids[word]]=1\n",
    "            X.append(vec)\n",
    "        \n",
    "        self.vec=X\n",
    "        \n",
    "        return X\n",
    "    \n",
    "    def predict(self):\n",
    "        '''\n",
    "            对self.vec进行预测,并将结果返回\n",
    "            \n",
    "            Parameters: None\n",
    "            Returns: DataFrame\n",
    "                     模型分类的结果，一共3列，由[句子,分割后的词，分类]组成。\n",
    "                     分别对应self.sen,self.words,分类结果\n",
    "        '''\n",
    "        self.load_words_id()\n",
    "        print('导入词id成功')\n",
    "        self.sen_split()\n",
    "        print('句子分裂完成')\n",
    "        self.sen2words()\n",
    "        print('词分裂完成')\n",
    "        self.word2vec()\n",
    "        print('词向量构建完成')\n",
    "        \n",
    "        y_pred=pd.DataFrame(self.model.predict(self.vec))\n",
    "        \n",
    "        result=pd.concat([self.sen,self.words,y_pred],axis=1)\n",
    "        result.columns=['句子','分割后的词','分类']\n",
    "        result.sort_values(['分类'],inplace=True)\n",
    "        \n",
    "        self.result=result\n",
    "        \n",
    "        return result\n",
    "    \n",
    "    def get_words_frequency(self):\n",
    "        '''\n",
    "            对self.result中分类的词进行统计,并将结果返回\n",
    "            \n",
    "            Parameters: None\n",
    "            Returns: list\n",
    "                     list中包含3个DataFrame，第一个DataFrame代表被分类为1(专业能力)的词的出现频率统计,\n",
    "                     后面2个DataFrame类似。\n",
    "                     \n",
    "        '''\n",
    "        words_fre=list()\n",
    "        \n",
    "        for i in np.arange(1,4):\n",
    "            dic=dict()\n",
    "            for words in self.result[ self.result['分类'] == i]['分割后的词'].values:\n",
    "                for word in words:\n",
    "                    dic[word]=dic.get(word,0)+1\n",
    "            dic=sorted(dic.items(),key=lambda x:x[1],reverse=True)\n",
    "            words_fre.append(pd.DataFrame(dic))\n",
    "                    \n",
    "        return words_fre"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-05T16:12:51.215942Z",
     "start_time": "2020-02-05T16:12:40.108972Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "导入词id成功\n",
      "句子分裂完成\n",
      "词分裂完成\n",
      "词向量构建完成\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>句子</th>\n",
       "      <th>分割后的词</th>\n",
       "      <th>分类</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>岗位职责  负责民品项目售前合同等/产品的Web前端模块的需求设计与开发并能够撰写相关文档</td>\n",
       "      <td>[岗位职责, 民品, 项目, 售前, 合同, 产品, Web, 前端, 模块, 需求, 设计...</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1244</th>\n",
       "      <td>根据产品设计和需求进行网站小程序等应用的前端开发; 与后端人员进行调试数据交互</td>\n",
       "      <td>[根据, 产品设计, 需求, 网站, 程序, 应用, 前端开发, 后端, 人员, 调试, 数...</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1243</th>\n",
       "      <td>职能类别Web前端开发      微信分享</td>\n",
       "      <td>[职能, 类别, Web, 前端开发, 微信, 分享]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1241</th>\n",
       "      <td>10有移动端</td>\n",
       "      <td>[10, 移动]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1235</th>\n",
       "      <td>熟悉网站设计</td>\n",
       "      <td>[网站, 设计]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1234</th>\n",
       "      <td>能快速定位和解决各主流浏览器之间的兼容问题</td>\n",
       "      <td>[快速, 定位, 解决, 主流, 浏览器, 之间, 兼容问题]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1227</th>\n",
       "      <td>保证Web页面访问终端的兼容性</td>\n",
       "      <td>[保证, Web, 页面, 访问, 终端, 兼容性]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1226</th>\n",
       "      <td>保证Web页面浏览器兼容性</td>\n",
       "      <td>[保证, Web, 页面, 浏览器, 兼容性]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1225</th>\n",
       "      <td>配合后台开发人员实现产品交互界面</td>\n",
       "      <td>[配合, 后台, 开发人员, 实现, 产品, 交互, 界面]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1224</th>\n",
       "      <td>岗位要求 根据模型完成Web页面制作</td>\n",
       "      <td>[岗位, 根据, 模型, 完成, Web, 页面, 制作]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1223</th>\n",
       "      <td>职能类别Web前端开发软件工程师   关键字AngularJScujscss      微信分享</td>\n",
       "      <td>[职能, 类别, Web, 前端开发, 软件, 工程师, 关键字, AngularJScuj...</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1218</th>\n",
       "      <td>了解mvc设计模式</td>\n",
       "      <td>[mvc, 设计模式]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1216</th>\n",
       "      <td>熟悉w3c网页标准</td>\n",
       "      <td>[w3c, 网页, 标准]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1215</th>\n",
       "      <td>对angular/bootstrap有一定的了解</td>\n",
       "      <td>[angular, bootstrap, 一定]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1213</th>\n",
       "      <td>精通JavaScripajax等web开发技术</td>\n",
       "      <td>[JavaScripajax, web, 开发技术]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1211</th>\n",
       "      <td>熟悉HTMLcss3相关特性</td>\n",
       "      <td>[HTMLcss3, 相关, 特性]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1204</th>\n",
       "      <td>优化网站静态资料加载速度</td>\n",
       "      <td>[优化, 网站, 静态, 资料, 加载, 速度]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1203</th>\n",
       "      <td>提高界面交互体验</td>\n",
       "      <td>[提高, 界面, 交互, 体验]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1202</th>\n",
       "      <td>配合后台工程师一起研讨前端技术实现方案</td>\n",
       "      <td>[配合, 后台, 工程师, 一起, 研讨, 前端, 技术, 实现, 方案]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1201</th>\n",
       "      <td>并保证兼容性和执行效率</td>\n",
       "      <td>[保证, 兼容性, 执行, 效率]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1200</th>\n",
       "      <td>持续的优化前端体验和页面响应速度</td>\n",
       "      <td>[持续, 优化, 前端, 体验, 页面, 响应速度]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1199</th>\n",
       "      <td>提升用户体验</td>\n",
       "      <td>[提升, 用户, 体验]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1245</th>\n",
       "      <td>根据产品需求</td>\n",
       "      <td>[根据, 产品, 需求]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1198</th>\n",
       "      <td>规划产品界面风格视觉效果和交互体验</td>\n",
       "      <td>[规划, 产品, 界面风格, 视觉效果, 交互, 体验]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1246</th>\n",
       "      <td>负责部分核心模块的的前端代码实现</td>\n",
       "      <td>[部分, 核心, 模块, 前端, 代码, 实现]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1257</th>\n",
       "      <td>熟悉各种浏览器的兼容性</td>\n",
       "      <td>[浏览器, 兼容性]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1291</th>\n",
       "      <td>熟悉Nodjs</td>\n",
       "      <td>[Nodjs]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1286</th>\n",
       "      <td>完成公司运营的其他开发需求</td>\n",
       "      <td>[完成, 公司, 运营, 开发, 需求]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1285</th>\n",
       "      <td>负责不断优化公司Web前端架构与技术</td>\n",
       "      <td>[不断, 优化, 公司, Web, 前端, 架构, 技术]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1284</th>\n",
       "      <td>负责公司项目或产品的前端WEB界面的维护与支持</td>\n",
       "      <td>[公司, 项目, 产品, 前端, WEB, 界面, 维护, 支持]</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1738</th>\n",
       "      <td>熟练掌握Objective-C和Swift语言</td>\n",
       "      <td>[熟练掌握, Objective, C, Swift, 语言]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1302</th>\n",
       "      <td>熟悉vue等前端开发框架</td>\n",
       "      <td>[vue, 前端开发, 框架]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1304</th>\n",
       "      <td>熟悉JavaScript的设计模式</td>\n",
       "      <td>[JavaScript, 设计模式]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1310</th>\n",
       "      <td>专业知识及专业技能要求 精通JavaScripajaHTMLCSS等web前端开发技术</td>\n",
       "      <td>[专业知识, 专业技能, JavaScripajaHTML, CSS, web, 前端开发,...</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1311</th>\n",
       "      <td>熟悉一种以上主流前端库或框架</td>\n",
       "      <td>[一种, 主流, 前端, 框架]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>194</th>\n",
       "      <td>-精通HTMLJavaScripAjaCSS等Web开发技术</td>\n",
       "      <td>[HTMLJavaScripAja, CSS, Web, 开发技术]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>561</th>\n",
       "      <td>熟练使用SQL并对MySQL数据库有一定了解</td>\n",
       "      <td>[熟练, SQL, MySQL, 数据库, 一定]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1776</th>\n",
       "      <td>利用HTML5/CSS3/JavaScript等各种Web技术进行产品的界面开发</td>\n",
       "      <td>[利用, HTML5, CSS, JavaScript, Web, 技术, 产品, 界面, 开发]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1780</th>\n",
       "      <td>熟悉主流JavaScript框架和库React/Vue/Angula</td>\n",
       "      <td>[主流, JavaScript, 框架, React, Vue, Angula]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>558</th>\n",
       "      <td>2年以上前端Java开发经验</td>\n",
       "      <td>[2年, 前端, Java, 开发, 经验]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1816</th>\n",
       "      <td>熟悉HTML5/CSS3</td>\n",
       "      <td>[HTML5, CSS]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1815</th>\n",
       "      <td>精通PC及移动端各种主流浏览器如IEChromFirefoSafari及移动端浏览器的区别漏...</td>\n",
       "      <td>[PC, 移动, 主流, 浏览器, IEChromFirefoSafari, 移动, 浏览器...</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>172</th>\n",
       "      <td>精通HTML和CSS3</td>\n",
       "      <td>[HTML, CSS]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1810</th>\n",
       "      <td>能熟练调试JS</td>\n",
       "      <td>[熟练, 调试, JS]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>177</th>\n",
       "      <td>熟悉javascript</td>\n",
       "      <td>[javascript]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1214</th>\n",
       "      <td>熟练掌握seajs和jquery</td>\n",
       "      <td>[熟练掌握, seajs, jquery]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1804</th>\n",
       "      <td>提升Web界面的友好和易用</td>\n",
       "      <td>[提升, Web, 界面, 友好, 易用]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1217</th>\n",
       "      <td>熟悉至少一种后台开发语言</td>\n",
       "      <td>[一种, 后台, 开发, 语言]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1219</th>\n",
       "      <td>熟悉jquery/YUI/extjs框架及其运作机理</td>\n",
       "      <td>[jquery, YUI, extjs, 框架, 及其, 运作, 机理]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1220</th>\n",
       "      <td>对算法数据结构以及后台开发PHP有一定了解</td>\n",
       "      <td>[算法, 数据结构, 后台, 开发, PHP, 一定]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1797</th>\n",
       "      <td>了解移动端开发有AppCaVuVant等框架开发更佳</td>\n",
       "      <td>[移动, 开发, AppCaVuVant, 框架, 开发, 更佳]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1231</th>\n",
       "      <td>熟练运用HTML5 / css3 / js / jquery / ajax 等Web前端技术</td>\n",
       "      <td>[熟练, 运用, HTML5, css3, js, jquery, ajax, Web, 前...</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1793</th>\n",
       "      <td>熟练掌握ES6语法</td>\n",
       "      <td>[熟练掌握, ES6, 语法]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1232</th>\n",
       "      <td>熟练运用VUEjs技术框架</td>\n",
       "      <td>[熟练, 运用, VUEjs, 技术, 框架]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1791</th>\n",
       "      <td>至少掌握一种JS框架如vue/react/angular等</td>\n",
       "      <td>[一种, JS, 框架, vue, react, angular]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1790</th>\n",
       "      <td>任职要求 熟悉原生HTMLCSSJS开发</td>\n",
       "      <td>[任职, 原生, HTML, CSS, JS, 开发]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1233</th>\n",
       "      <td>精通HTML/DIV/CSS/XML/JSON</td>\n",
       "      <td>[HTML, DIV, CSS, XML, JSON]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1782</th>\n",
       "      <td>掌握至少一门非前端开发语言如 Java 等     职能类别高级软件工程师软件工程师    ...</td>\n",
       "      <td>[一门, 前端开发, 语言, Java, 职能, 类别, 高级, 软件, 工程师, 软件, ...</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1779</th>\n",
       "      <td>熟练使用HTML/CSS/Javascript等前端技术</td>\n",
       "      <td>[熟练, HTML, CSS, Javascript, 前端, 技术]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>559</th>\n",
       "      <td>熟悉JavaScripjQuerAjaHTMLCSS等Web前端技术</td>\n",
       "      <td>[JavaScripjQuerAjaHTML, CSS, Web, 前端, 技术]</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2101 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                     句子  \\\n",
       "0         岗位职责  负责民品项目售前合同等/产品的Web前端模块的需求设计与开发并能够撰写相关文档   \n",
       "1244            根据产品设计和需求进行网站小程序等应用的前端开发; 与后端人员进行调试数据交互   \n",
       "1243                              职能类别Web前端开发      微信分享   \n",
       "1241                                             10有移动端   \n",
       "1235                                             熟悉网站设计   \n",
       "...                                                 ...   \n",
       "1790                               任职要求 熟悉原生HTMLCSSJS开发   \n",
       "1233                            精通HTML/DIV/CSS/XML/JSON   \n",
       "1782  掌握至少一门非前端开发语言如 Java 等     职能类别高级软件工程师软件工程师    ...   \n",
       "1779                       熟练使用HTML/CSS/Javascript等前端技术   \n",
       "559                  熟悉JavaScripjQuerAjaHTMLCSS等Web前端技术   \n",
       "\n",
       "                                                  分割后的词  分类  \n",
       "0     [岗位职责, 民品, 项目, 售前, 合同, 产品, Web, 前端, 模块, 需求, 设计...   1  \n",
       "1244  [根据, 产品设计, 需求, 网站, 程序, 应用, 前端开发, 后端, 人员, 调试, 数...   1  \n",
       "1243                        [职能, 类别, Web, 前端开发, 微信, 分享]   1  \n",
       "1241                                           [10, 移动]   1  \n",
       "1235                                           [网站, 设计]   1  \n",
       "...                                                 ...  ..  \n",
       "1790                        [任职, 原生, HTML, CSS, JS, 开发]   3  \n",
       "1233                        [HTML, DIV, CSS, XML, JSON]   3  \n",
       "1782  [一门, 前端开发, 语言, Java, 职能, 类别, 高级, 软件, 工程师, 软件, ...   3  \n",
       "1779                [熟练, HTML, CSS, Javascript, 前端, 技术]   3  \n",
       "559           [JavaScripjQuerAjaHTML, CSS, Web, 前端, 技术]   3  \n",
       "\n",
       "[2101 rows x 3 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "classifier=JobinfoClassifier('SVM.model',df,'stopwords.txt','addwords.txt','words_id.txt')\n",
    "result=classifier.predict()\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-05T16:12:55.708752Z",
     "start_time": "2020-02-05T16:12:55.594040Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>前端</td>\n",
       "      <td>212</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>开发</td>\n",
       "      <td>178</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>技术</td>\n",
       "      <td>112</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>前端开发</td>\n",
       "      <td>107</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>产品</td>\n",
       "      <td>104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>微信</td>\n",
       "      <td>104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Web</td>\n",
       "      <td>91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>分享</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>设计</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>职能</td>\n",
       "      <td>86</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>类别</td>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>工程师</td>\n",
       "      <td>80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>完成</td>\n",
       "      <td>67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>优化</td>\n",
       "      <td>66</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>项目</td>\n",
       "      <td>63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>公司</td>\n",
       "      <td>63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>页面</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>软件</td>\n",
       "      <td>58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>代码</td>\n",
       "      <td>58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>需求</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>交互</td>\n",
       "      <td>53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>体验</td>\n",
       "      <td>53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>实现</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>用户</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>框架</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>关键字</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>相关</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>根据</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>团队</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>性能</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1576</th>\n",
       "      <td>结果</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1577</th>\n",
       "      <td>确认</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1578</th>\n",
       "      <td>webpacgulp</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1579</th>\n",
       "      <td>提炼</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1580</th>\n",
       "      <td>有利于</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1581</th>\n",
       "      <td>经常</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1582</th>\n",
       "      <td>版式</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1583</th>\n",
       "      <td>图形界面</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1584</th>\n",
       "      <td>工作效率</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1585</th>\n",
       "      <td>沟通</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1586</th>\n",
       "      <td>关系</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1587</th>\n",
       "      <td>htmlcsES56</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1588</th>\n",
       "      <td>整套</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1589</th>\n",
       "      <td>有过</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1590</th>\n",
       "      <td>心理</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1591</th>\n",
       "      <td>并会</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1592</th>\n",
       "      <td>考虑</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1593</th>\n",
       "      <td>从事</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1594</th>\n",
       "      <td>为人正直</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1595</th>\n",
       "      <td>诚恳</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1596</th>\n",
       "      <td>分解</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1597</th>\n",
       "      <td>分派</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1598</th>\n",
       "      <td>软件设计</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1599</th>\n",
       "      <td>管理控制</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1600</th>\n",
       "      <td>真实</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1601</th>\n",
       "      <td>网上</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1602</th>\n",
       "      <td>查询</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1603</th>\n",
       "      <td>面试</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1604</th>\n",
       "      <td>最好</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1605</th>\n",
       "      <td>画面</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1606 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         0    1\n",
       "0       前端  212\n",
       "1       开发  178\n",
       "2       技术  112\n",
       "3     前端开发  107\n",
       "4       产品  104\n",
       "...    ...  ...\n",
       "1601    网上    1\n",
       "1602    查询    1\n",
       "1603    面试    1\n",
       "1604    最好    1\n",
       "1605    画面    1\n",
       "\n",
       "[1606 rows x 2 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "classifier.get_words_frequency()[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## JobinfoTrainer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-05T16:13:00.337823Z",
     "start_time": "2020-02-05T16:12:59.320948Z"
    },
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "class JobinfoTrainer():\n",
    "    '''\n",
    "        Constructor:\n",
    "                    JobinfoTrainer(stopwords,addwords,df)\n",
    "                    \n",
    "                    stopwords 停用词txt文件 一行一个词\n",
    "                    addwords  增加词txt文件 一行一个词\n",
    "                    df        DataFrame\n",
    "                              default = None\n",
    "                              模型训练用数据\n",
    "                   \n",
    "                    \n",
    "        Attributes:\n",
    "                    model      SVC\n",
    "                            训练后的模型\n",
    "                    df      DataFrame\n",
    "                            模型训练用数据\n",
    "                    stopwords str \n",
    "                              stopwords的txt文件地址\n",
    "                    addwords  str \n",
    "                              addwords的txt文件地址\n",
    "                    ids     dict\n",
    "                            模型训练学习到的词  key:词，value:id\n",
    "                    X_train Series\n",
    "                            模型训练集\n",
    "                    X_test  Series\n",
    "                            模型测试集\n",
    "                    y_train DataFrame\n",
    "                            模型训练集类别\n",
    "                    y_test  DataFrame\n",
    "                            模型测试集类别\n",
    "                    words_id str\n",
    "                             学习到的词id文件保存地址    \n",
    "                    v_X_train list\n",
    "                              转换为词向量矩阵的训练集，list每个元素为array(词向量)\n",
    "                    v_X_test list\n",
    "                             转换为词向量矩阵的测试集，list每个元素为array(词向量)\n",
    "        \n",
    "        Functions:\n",
    "                    transform() 将句子的标签进行转换\n",
    "                    read_excels_from_dir() 读取文件夹中所有的excel，合并其中的内容\n",
    "                    sen2words() 将句子化为单词\n",
    "                    word2vec()  将单词化为词向量\n",
    "                    get_words_id() 获得训练数据的词id，并把它写入txt文件\n",
    "                    \n",
    "                    fit() 训练模型\n",
    "                    get_score() 查看模型的训练效果\n",
    "                    dump_model() 将模型导出\n",
    "    '''\n",
    "    \n",
    "    \n",
    "\n",
    "    def __init__(self,stopwords,addwords,df=None):\n",
    "        \n",
    "        self.df=df\n",
    "        \n",
    "        if df:\n",
    "            print('训练用Dataframe已经获得')\n",
    "        else:\n",
    "            print('未输入训练用DataFrame,请手动赋予或使用read_excels_from_dir()等来赋予训练集')\n",
    "        \n",
    "        self.model=[]\n",
    "        self.stopwords=stopwords\n",
    "        self.addwords=addwords\n",
    "        self.ids=[]\n",
    "        \n",
    "        self.X_train=[]\n",
    "        self.X_test=[]\n",
    "        self.y_train=[]\n",
    "        self.y_test=[]\n",
    "        \n",
    "        self.v_X_train=[]\n",
    "        self.v_X_test=[]\n",
    "        \n",
    "    def transform(self,i):\n",
    "        '''\n",
    "            将训练数据的标签进行转换,如果标签为1,2,3形式则不使用该方法\n",
    "            \n",
    "            Parameters: int\n",
    "                        i\n",
    "            Returns: int\n",
    "                     转换后的标签\n",
    "        '''\n",
    "        if all(i == [1,0,0]):\n",
    "            j=1\n",
    "        elif all(i == [0,1,0]):\n",
    "            j=2\n",
    "        else:\n",
    "            j=3\n",
    "        return j\n",
    "    \n",
    "    def read_excels_from_dir(self,f_dir,tran=True):\n",
    "        '''\n",
    "             读取文件夹内的所有excel，并将其合并为一个DataFrame。\n",
    "             **文件夹内应该只有excel文件**\n",
    "             \n",
    "             Parameters: str\n",
    "                         f_dir 文件夹地址\n",
    "                         \n",
    "                         bool\n",
    "                         tran 是否要使用transform()\n",
    "             Returns: DataFrame\n",
    "                      合并excel后的DataFrame\n",
    "        '''\n",
    "        files=os.listdir(f_dir)\n",
    "\n",
    "        dir_name=f_dir+'/'\n",
    "\n",
    "        df=pd.DataFrame()\n",
    "\n",
    "        for f in files:\n",
    "            f=dir_name+f\n",
    "            t_df=pd.read_excel(f)\n",
    "            df=pd.concat([df,t_df])\n",
    "        if tran == True:\n",
    "            df['类别']=df.iloc[:,1:].apply(self.transform,axis=1)\n",
    "        df.drop(['专业能力','个人能力','工具使用'],inplace=True,axis=1)\n",
    "        df=df.reset_index(drop=True)\n",
    "        \n",
    "        self.df=df\n",
    "\n",
    "        return df\n",
    "    \n",
    "    def sen2words(self):\n",
    "        '''\n",
    "            将训练数据的句子转换为词\n",
    "            \n",
    "            Parameters: None\n",
    "            Returns: DataFrame\n",
    "                     转变成词后的训练集\n",
    "        '''\n",
    "        \n",
    "        with open(self.stopwords,'r+',encoding='utf8') as f:\n",
    "            stopwords=[ i.strip('\\n') for i in f.readlines()]\n",
    "    \n",
    "        jieba.load_userdict(self.addwords)\n",
    "        words=list()\n",
    "        for sentence in self.df.iloc[:,0].values:\n",
    "            word=jieba.lcut(sentence)\n",
    "            \n",
    "            temp=list()\n",
    "            for w in word:\n",
    "                if w not in stopwords and w!='\\xa0':\n",
    "                    temp.append(w)\n",
    "            words.append(temp)\n",
    "        self.df.iloc[:,0]=words\n",
    "    \n",
    "        return df\n",
    "    \n",
    "    def get_words_id(self,f_id):\n",
    "        '''\n",
    "            获得训练数据的词ID\n",
    "            \n",
    "            Parameters: str\n",
    "                        f_id 词id文件保存的地址\n",
    "            Returns: DataFrame\n",
    "                     转变成词后的训练集\n",
    "            \n",
    "        '''\n",
    "        freq_counter=collections.Counter(itertools.chain(*(self.df.iloc[:,0])))\n",
    "        freq_counter=sorted(freq_counter.items(),key=lambda x:x[1],reverse=True)\n",
    "\n",
    "        words,_=zip(*(filter(lambda x:x[1]>=2,freq_counter)))\n",
    "\n",
    "        print('一共分得{0}个词'.format(len(words)))\n",
    "\n",
    "        words_id=dict(zip(words,range(len(words))))\n",
    "\n",
    "        try:\n",
    "            with open(f_id,'w',encoding='utf8') as f:\n",
    "                t=0\n",
    "                for i in words_id.items():\n",
    "                    i=list(i)\n",
    "                    i.append(str(i[1]))\n",
    "                    i.append('\\n')\n",
    "                    i[1]='-'\n",
    "                    t=i\n",
    "                    \n",
    "                    f.writelines(i)\n",
    "        except Exception as e:\n",
    "            print(\"id文件写入失败了...\")\n",
    "            print(e)\n",
    "            print(i)\n",
    "            return \n",
    "\n",
    "        print(\"id文件写入完成\")\n",
    "        self.ids=words_id\n",
    "        \n",
    "        return words_id\n",
    "    \n",
    "    def word2vec(self,df,word_id):\n",
    "        '''\n",
    "            将训练集转换为词向量\n",
    "            \n",
    "            Parameters: DataFrame\n",
    "                        df 需要转换为词向量的训练集\n",
    "                        dict\n",
    "                        word_id 模型训练学习到的词  key:词，value:id\n",
    "                        \n",
    "            Returns: DataFrame\n",
    "                     转变成词向量后的训练集\n",
    "        '''\n",
    "        X=list()\n",
    "        for t in df:\n",
    "            vect=array.array('l',[0]*len(word_id))\n",
    "            for word in t:\n",
    "                if word not in word_id:\n",
    "                    continue\n",
    "                vect[word_id[word]]=1\n",
    "            X.append(vect)\n",
    "        return X\n",
    "    \n",
    "    def get_score(self,y_test,y_pred,cv):\n",
    "        '''\n",
    "            查看模型训练后的结果\n",
    "            \n",
    "            Parameters: array-like\n",
    "                        y_test 测试集标签\n",
    "                        \n",
    "                        array-like\n",
    "                        y_pred 模型预测的结果\n",
    "                        \n",
    "                        int \n",
    "                        cv 交叉验证的次数\n",
    "                        \n",
    "            Returns: None\n",
    "            \n",
    "        '''\n",
    "    \n",
    "        f1=f1_score(y_test,y_pred,average='macro')\n",
    "        p=precision_score(y_test,y_pred,average='macro')\n",
    "        r=recall_score(y_test,y_pred,average='macro')\n",
    "        a=accuracy_score(y_test,y_pred)\n",
    "        scores=cross_val_score(self.model,\\\n",
    "                self.v_X_train,self.y_train.values.ravel(),cv=cv)\n",
    "\n",
    "        print('f1:{0}'.format(f1))\n",
    "        print('p:{0}'.format(p))\n",
    "        print('r:{0}'.format(r))\n",
    "        print('a:{0}'.format(a))\n",
    "        print(\"交叉验证得分{0}\".format(np.mean(scores)))\n",
    "    \n",
    "    def fit(self,cv,f_id):\n",
    "        '''\n",
    "            训练模型\n",
    "            \n",
    "            Parameters: int \n",
    "                        cv 交叉验证的次数\n",
    "                        \n",
    "                        str\n",
    "                        f_id 词id文件位置\n",
    "                        \n",
    "            Returns: SVC\n",
    "                     训练完后的模型\n",
    "            \n",
    "        '''\n",
    "        self.get_words_id(f_id)\n",
    "        self.X_train,self.X_test,self.y_train,self.y_test=train_test_split(\\\n",
    "                            self.df.iloc[:,0],self.df.iloc[:,1:],test_size=0.2)\n",
    "        self.v_X_train=self.word2vec(self.X_train,self.ids)\n",
    "        self.v_X_test=self.word2vec(self.X_test,self.ids)\n",
    "        \n",
    "        self.model=svm.SVC(kernel='linear')\n",
    "        self.model.fit(self.v_X_train,self.y_train.values.ravel())\n",
    "        \n",
    "        y_pred=self.model.predict(self.v_X_test)\n",
    "        \n",
    "        self.get_score(self.y_test,y_pred,cv)\n",
    "        \n",
    "        print('训练完成')\n",
    "        \n",
    "        return self.model\n",
    "    \n",
    "    def dump_model(self,f_model):\n",
    "        '''\n",
    "            将训练完的模型导出\n",
    "            \n",
    "            Parameters: str\n",
    "                        f_model 模型导出的文件名\n",
    "                        \n",
    "            Returns: None\n",
    "        '''\n",
    "        joblib.dump(self.model,f_model)\n",
    "        print('模型已经导出')\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-05T16:13:55.863744Z",
     "start_time": "2020-02-05T16:13:02.790409Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "未输入训练用DataFrame,请手动赋予或使用read_excels_from_dir()等来赋予训练集\n",
      "一共分得1928个词\n",
      "id文件写入完成\n",
      "f1:0.9030701869839515\n",
      "p:0.9087694487467389\n",
      "r:0.9030499433392364\n",
      "a:0.9044117647058824\n",
      "交叉验证得分0.8767049219648833\n",
      "训练完成\n",
      "模型已经导出\n"
     ]
    }
   ],
   "source": [
    "t=JobinfoTrainer('stopwords.txt','addwords.txt')\n",
    "t.read_excels_from_dir('doneLabel')\n",
    "t.sen2words()\n",
    "t.fit(3,'test.txt')\n",
    "t.dump_model('SVM2.model')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "307px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
